package java_thinking.unit_14._14_2;

import java.util.Arrays;
import java.util.List;

/**
 * @Description :  如果是Circle则不旋转
 * @author: cww
 * @DateTime: 2019/3/26 20:30
 */
abstract class RShape {
    void draw() { System.out.println(this + ".draw()"); }
    abstract public String toString();
    void rotate(int degrees) {
        System.out.println("Rotating " + this +
                " by " + degrees + " degrees");
    }
}
class RCircle extends RShape {
    public String toString() { return "Circle"; }
    void rotate(int degrees) {
        throw new UnsupportedOperationException();
    }
}

class RSquare extends RShape {
    public String toString() { return "Square"; }
}

class RTriangle extends RShape {
    public String toString() { return "Triangle"; }
}

public class E05 {
    static void rotateAll(List<RShape> shapeList){
        for (RShape rShape : shapeList){
            if (!(rShape instanceof RCircle)){
                rShape.rotate(45);
            }
        }
    }
    public static void main(String[] args) {
        List<RShape> rShapes = Arrays.asList(new RCircle(),new RSquare(),new RTriangle());
        rotateAll(rShapes);
    }
}
